home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 3848 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  2.0 KB

  1. Path: nntp.teleport.com!craigl
  2. From: craigl@teleport.com (Craig Lovegren)
  3. Newsgroups: comp.lang.c,comp.lang.c++,alt.msdos.programmer
  4. Subject: Re: Clearing the keyboard buffer
  5. Followup-To: comp.lang.c,comp.lang.c++,alt.msdos.programmer
  6. Date: 26 Jan 1996 05:19:31 GMT
  7. Organization: Teleport - Portland's Public Access (503) 220-1016
  8. Message-ID: <4e9o93$9g0@maureen.teleport.com>
  9. References: <4dtqi4$60u@cdc2.cdc.net> <4e07uh$oqq@huron.eel.ufl.edu>
  10. NNTP-Posting-Host: linda.teleport.com
  11. X-Newsreader: TIN [version 1.2 PL2]
  12.  
  13. Daniel P Hudson (afn03257@freenet2.freenet.ufl.edu) wrote:
  14. : In article <4dtqi4$60u@cdc2.cdc.net>,
  15. : mart@vianet.on.ca (Mart) wrote:
  16.  
  17. :  > I'm using Turbo C++ v. 3.1 and I need to be able to clear the keyboard
  18. :  > BTW, this following bit of code wouldn't work :
  19.  
  20. :  > while(kbhit()) getch();
  21.  
  22. :  > Because I want the user to be able to just keep pushing the same key,
  23. :  > making the above loop infinitly. If I don't clear the keyboard buffer, 
  24. :  > my code will continue believing that the user is pushing a key, even 
  25. :  > though their not.
  26.  
  27. :  Huh? Once the buffer is caught up, it shouldn't continue, but you
  28. :  might want to try fflush(stdin); just the same. The code you had
  29. :  should work as soon as it has read through all the keystrokes currently
  30. :  stored, the only way it should have a situation like you describe is if
  31. :  the user presses a key after it has executed, in which case your only 
  32. :  prevention would be to disable the keyboard.
  33.  
  34. Well... what about typematic delays?  If, while you are in DOS, you press 
  35. and hold a key... it will first appear... then wait... then continue to 
  36. fill up the line with that character.  In this instance the line will 
  37. execute and process the first character... then the typematic delay 
  38. hits... the line will then finish since no more keys have been hit (still 
  39. in the delay) once the delay is over however it will continue to fill the 
  40. buffer up once again.  At least that is how I understand it.
  41.  
  42. --
  43. Real Life: Craig R. Lovegren
  44. CyberLife: craigl@teleport.com
  45. IRC  Life: Son-Of-Yo
  46.